package com.shihb.chapter05matchcase

/**
 * Description:匹配元组
 *
 * @author shihb
 * @date 2020/9/30 14:53
 */
object Demo04MatchTuple {

  def main(args: Array[String]): Unit = {
    for (pair <- Array((0, 1), (1, 0), (1, 1), (0, 0, 2),(4,3,3,3))) {
      val res = pair match {
        case (0, _) => (0, "Any") //_是表示匹配任意，但忽略不要
        case (x, 0) => (x, 0)
        case (x, y) => (x, y)
        case (x, y,z) => (x, y,z)
        case _ => "other"
      }
      println(res)
    }


  }
}
